package com.nuanshui.heatedloan.web.appsystem;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.nuanshui.heatedloan.baseservice.facade.CommonConfigService;
import com.nuanshui.heatedloan.baseservice.form.CommonConfigForm;
import com.nuanshui.heatedloan.baseservice.vo.CommonConfigVO;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.entity.cms.security.UserVO;
import com.nuanshui.heatedloan.pageable.Pager;
import com.nuanshui.heatedloan.web.ApiController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/cms/manage/commonconfig")
public class CommonConfigController extends ApiController{

	@Reference(url = GlobalParam.BASESERVICE_DUBBO_SERVER, timeout = GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.BASESERVICE_DUBBO_SERVER_VERSION)
	private CommonConfigService commonConfigService;

	@RequestMapping("/list")
	public String list(Pager<CommonConfigVO> pager, String query){
		CommonConfigForm form = JSON.parseObject(query, CommonConfigForm.class);
		pager = commonConfigService.list(pager,form);
		return success( pager.asHashMap());
	}
	
	@RequestMapping("/update")
	public String update(CommonConfigVO item){
		commonConfigService.update(item);
		return success();
	}
	
	@RequestMapping(value="/create")
	public String create(CommonConfigVO item){
		commonConfigService.save(item);
		return success();
	}
	
	@RequestMapping(value="/delete")
	public String delete(String id){
		commonConfigService.delete(id);
		return success();
	}
	
}
